
<html>
    <body>

        <div>
            <h1>Chiron Basics</h1>
            <p>
                In this lesson, you will learn about the primitives 
                and utility functions that
                <tt>base.js</tt> provides to bring the JavaScript
                into the same class as other dynamic languages
                like Python and Ruby:
            </p>
            <ul>
                <li><a href="#iter">iteration</a></li>
                <li><a href="#collect">collections</a></li>
                <li><a href="#type">types</a></li>
            </ul>
            <p>
                You may press <tt>enter</tt> or <tt>return</tt>
                at any time in this tutorial to proceed to the
                next section.  You can also enter <tt>/prev</tt>
                to return to the previous lesson, or <tt>/index</tt>
                to return to this section.
            </p>
            <p><a href="#intro">next</a> <tt>enter</tt></p>
        </div>

        <div>
            <h2>Introduction</h2>
            <p>
                JavaScript only provides the most primitive functions and types.
                Chiron's <tt>base.js</tt> module creates a new level of
                abstraction.  Where you used <tt>Object</tt>s for new types,
                you can use <tt>Base</tt>; where you used <tt>Object</tt> as 
                a hash table, you can use <tt>Dict</tt>; where you used
                <tt>Array</tt> for lists, you can use <tt>List</tt>.  These
                new primitives provide a more abstract interface, a more
                comphrehensive set of member functions, iterability,
                readable representations, and more general behavior.  For example,
                a <tt>Dict</tt> can have any type for a key, considering
                numbers and strings distinct, emulating a real
                hash table.  <tt>List</tt> can be used as a copy constructor
                reliably, unlike <tt>Array</tt>.
            </p>
            <p>
                To get these names from <code>base.js</code> in your
                module, you need to <code>include</code> them:
            </p>
            <p><code command>include('base.js')</code></p>
        </div>

        <div>
            <p>
                Assuming I've run this code,
                <code command>this.a = dict([[1, 'a'], ['1', 'b']])</code>,
                you can access item <code>1</code> and <code>"1"</code>
                indepedently.
            </p>
            <p>Try <code>a.getItem(1)</code> and <code>a.getItem('1')</code></p>
        </div>

        <div>
            <p>
                You can construct an empty list with <code>list()</code>.
            </p>
            <p>
                You can create a list from any other iterable object.
                Iterables include <code>Arrays</code>, <code>Objects</code>, 
                <code>Lists</code>, <code>Dicts</code>, <code>Ranges</code>,
                <code>Iters</code>, <code>Sets</code>, <code>Strings</code>,
                and user defined types that implement the <tt>iter</tt>
                member function.
            </p>
            <p>
                Create a copy of <code>a</code> by using the <code>list</code>
                function: <code>list(a)</code>.
            </p>
            <p>
                <code command>this.a = [1, 2, 3]</code>
            </p>
        </div>

        <div>
            <p>
                Chiron's base types are all based on iterations, a type
                that can produce finite or indefinite, ordered elements.
                This includes sequences and ranges.
            </p>
            <p>
                Here's a sample range: <code command>range(0, 10)</code>
            </p>
        </div>

        <div>
            <p>You can convert ranges to lists using the copy constructor:</p>
            <p><code command>list(range(10))</code></p>
        </div>

        <div>
            This concludes our tutorial on Chiron basics.
        </div>

        <div>
            <a name="iter"></a>
            <h2>Iteration</h2>
        </div>

        <div>
            <a name="collect"></a>
            <h2>Collections</h2>
        </div>

        <div>
            <a name="type"></a>
            <h2>Types</h2>
        </div>



        dir
        help

        list, List
        dict, Dict
        set, Set
        object, Object
        array, Array
        copy
        to
        as

        string
        repr
        hash

        iter, Iter, stopIteration
        range
        count
        seq

        range(10).apply(add)
        count(10).apply(mul)
        seq(1, 1, add).to(range(10))

        range(10)
        range(10).list()
        count(10).list()
        range(1, 5).list()
        enumerate
        iter
            list
            string
            array
            object
        to

        range
        count
        seq
        list
        dict

        dir

        type
        Base

    </body>
</html>
